package com.abc.springcloud.controller;

import com.abc.springcloud.entities.CommonResult;
import com.abc.springcloud.entities.Payment;
import com.abc.springcloud.service.PaymentFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Describe
 * @Author wangzhe
 * @Date 2020/10/2 22:54
 */
@RestController
@Slf4j
public class OrderFeignController {

    @Autowired
    private PaymentFeignService paymentFeignService;

    @GetMapping(value = "/consumer/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id) {
        return paymentFeignService.getPaymentById(id);
    }

    //测试OpenFeign的超时控制
    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {

        //OpenFeign-ribbon，客户端默认等待1秒钟拿到结果
        return paymentFeignService.paymentFeignTimeout();
    }

}
